#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	char arr[100];
	fgets(arr, 100, stdin);
	int count = 0;
	int i = 0;
	int j = 0;
	int flag = 0;
	int len = strlen(arr);
	for (i = 0; i < len; i++) {
		if (isalpha(arr[i])) {
			flag = 1;
		}
		if (arr[i] == ' ' && flag == 1)
			count++;
	}
	int ret = 0;
	char nowword[9] = "";
	char maxword[9] = "";
	char longestword[9] = "";
	int longest = 0;
	for (i = 0; i < len; i++) {
		ret = 0;
		while (i < len && arr[i] != ' ') {
			nowword[ret++] = arr[i];
			nowword[ret] = '\0';
			i++;
		}
		int length = strlen(nowword);
		if (length > longest) {
			longest = length;
			strcpy(longestword, nowword);
		}
		if (strcmp(nowword, maxword) > 0) {
			strcpy(maxword, nowword);
		}

	}

	printf("%d %s %s\n", count + 1, maxword, longestword);
	return 0 ;
}